4.7 Tabstop Input Box

It is a tabstop version of the Inbox Object. The TSInbox class is a template class derived from both tabstop and Inbox classes. Use of it simplifies programming compared with the Inbox Object. You must only declare TSInbox instance before the Loop function and it will be included into the current button system and will be automatically driven by the button system. No further calls are needed. Automatically TSInbox instance deals only with the one variable declared in constructor. The template parameter is the type of that variable. You can write a processing procedure and attach it to the TSInbox Object. In case of successful input the value of the variable is transferred to this procedure which can process it and must return the new value of the variable which is stored as an ultimate value.

Note that you can call Scanf method inherited from the Inbox class if you want to scan other variables. TSInbox is FIXED and UNFRAMED. This features cannot be changed.

Constructor:

TSInbox(
int x0,int y0, // coord. of LEFT-TOP corner of Indicator
char * title, // title of Inbox
int columns, // size of box in characters
T * variable, // variable and its formats
char * scanfmt, // for scanning the new value
char * printfmt,// and printing the current value
//———- Hereafter are defaults
T (far *proc)(T) = NULL,// variable processing procedure,
int titlefont=SMALL_FONT,int titlefontsize=4,// title font
plaquecolors obxcolcnfg=plaquecoldflt,// colors of frame
outboxcolors ibxcolors=ibxcoldflt); // and display

Here T is a template parameter. If the pointer to the processing procedure is NULL then no call is made. The processing procedure must be far and return the new value of the inputed variable.

Data members:

All are inherited from the object base class ( see sect. 4 ).

Methods:

Includes all methods of Inbox (sect.4.6), Outbox (sect.4.5) and object (sect.4) classes. The Paint method is inherited from the Inbox class.

void Refresh(void);

Clears display and prints the current value of variable.

virtual void Activate(void);

Makes the TSInbox Object the active tabstop object in the current button system. Then the current value of the variable is highlighted. This can be done from console striking Tab or Shift-Tab keys one or several times.

Example:

butsystem bsDlg;         // Declare the button system
 TSInbox<float>
   tibVol( 0, 0, "Volume (sm):", 12, &Vol, "%f", "%.2f");

 TSInbox<float>
   tibK2( 0 , tibVol.ymax, "Formation factor:", 12, &K2, "%f", "%.2f");

 butgrp grp1( (tibVol.xmax-tibVol.x0)/2 , tibK2.ymax+30 , 70, 21, VERT, 2);
  button butNorm( "Norm", 'n','N', bpNorm);
  button butHelp( "Help", 'h','H', bpHelp);
  button butQuit( "Quit", 'q','Q', bpQuit, 0,1,quittexcol,quitbutcol);

         // Paint the button system
 tibVol.Paint();
 tibK2.Paint();
 tibVol.Refresh();
 tibK2.Refresh();
 grp1.Paint();

         // Turn on the button system
 bsDlg.NextButton();
 bsDlg.Loop(procDummy);